import instance from "@/utils/request";

export const showCart=()=>{
    let url='/cartItems';

    return instance.get(url);
}

export const buyNowAtOnce=(ItemId)=>{
    let url='/user/buyItem';
    // const body={
    //     itemId:ItemId,
    //     number:1
    // }
    return instance.put(url, null,{
        params:{
            itemId:ItemId,
            number:1
        },
    });
}

export const buyFromCartService=()=>{
    let url='/user/newOrder';
    return instance.get(url);
}

export const getOrderInfoFromOrderIdService=(OrderId)=>{
    let url='/orders/'+OrderId;
    return instance.get(url);
}
export const cancelOrderService=(OrderId)=>{
    let url='/cancelOrders/'+OrderId;
    return instance.delete(url);
}

export const getOrderItemService=(OrderId)=>{
    let url='/lineItems/order/'+OrderId;
    return instance.get(url);
}
export const goPayFormService=(orderId,OrderData)=>{
    let url='/orders/'+orderId;
    return instance.put(url,OrderData)
}

export const returnOrderService=(orderId)=>{
    let url ='/returnOrders/'+orderId;
    return instance.delete(url);
}

export const removeItemFromCart=(itemId)=>{
    let url='/cartItems/'+itemId;
    return instance.delete(url);
}
export const payOrderService=(OrderNo)=>{
    let url='/orders/pay/'+OrderNo;
    return instance.post(url);
}

